<!-- 我的喜欢页面 -->
<template>
  <view>
    <TabSelector :tabs="tabs" :initialIndex="0" @change="handleChange" />
    <view v-if="!flag">
      <view v-if="!list.length">
        <NoData />
      </view>
      <view v-else>
        <Likelist :data="list" />
      </view>
    </view>
    <view v-else>
      <view v-if="!likemeList.length">
        <NoData />
      </view>
      <view v-else>
        <Likelist :data="likemeList" />
      </view>
    </view>
  </view>
</template>
<script setup>
import { onMounted, ref } from 'vue'
import { getMylikeItemApi, getLikeMyItemApi } from '@/services/mylike'
import TabSelector from '@/pages/my/MyMoney/TabSelector.vue'
import NoData from '@/components/NoData/NoData.vue'
import Likelist from '@/pages/my/MyLike/Likelist.vue'
const tabs = [
  { label: '我喜欢', value: 'mylike' },
  { label: '喜欢我', value: 'likeme' },
]
const flag = ref(false)
const handleChange = (index) => {
  flag.value = index === 1
}
//我喜欢的数据
const list = ref([])

//喜欢我的数据
const likemeList = ref([])
const userId = uni.getStorageSync('userInfo').id || ''
const getmylike = async () => {
  const res = await getMylikeItemApi(userId)
  list.value = res.data.result
  console.log(res, 'mylike');
  
}

const getlikeme = async () => {
  const res = await getLikeMyItemApi(userId)
  likemeList.value = res.ls
  console.log(res, 'likeme');
}

onMounted(() => {
  getlikeme()
  getmylike()
})
</script>

<style lang="scss" scoped></style>
